<!DOCTYPE HTML>
<html lang="de">
    <head>
        <title>Hyphenator.js &ndash; Test 14</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <style type="text/css">
            body {
                width:50%;
                margin-left:25%;
                margin-right:25%;
            }
            #test {
            	background-color: #ffd6d6;
            }
            #ref {
            	background-color: #d6ffd6;
            }
        </style>
    </head>
    <body>
		<p><a href="index.html">&lt;&lt; index</a> | <a href="test13.html">&lt;- Prev</a> | <a href="test15.html">Next -&gt;</a></p>
        <h1>Test 14</h1>
        <p id="desc">Measuring time to hyphenate a word.</p>

		<p id="output" class="hyphenate test">Silbentrennung</p>
 		<p id="ref">hyphenateWord('de','Silbentrennung')-> Sil|ben|tren|nung :: 0._ _ _ms</p>
        <script type="text/javascript">
				function cb() {
					var out=document.getElementById('output').firstChild;
					var res,start,end,times = 1000, received = 0;
					var hyphenator = new Worker('../Hyphenator_worker.js');
					hyphenator.postMessage(JSON.stringify({
						type: 'config',
						wordHyphenChar: '|'
					}));
					hyphenator.onmessage = function(e) {
						received++;
						if (received === times) {
							end=new Date().getTime();
							out.data="hyphenateWord('de','Silbentrennung')-> "+JSON.parse(e.data).text+" :: "+((end-start)/times)+"ms\n";
							if (parent != window) {
								var msg = {
									desc: 'Hyphenating a word took: ' + ((end-start)/times) + 'ms',
									index: 14,
									result: 'passed'
								};
								parent.postMessage(JSON.stringify(msg), window.location.href);
							}
						}
					};
					var msg = JSON.stringify({
						type: 'hyphenate',
						text: 'Silbentrennung',
						lang: 'de'
					});
					start=new Date().getTime();
					for(var i=0; i<times; i++) {
						hyphenator.postMessage(msg);
					}
				}
				cb();
		</script>

     </body>
</html>